﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.WaterReadingChangeMeassure.Search;

namespace University.Workshop.Presentation.WaterReading
{
    /// <summary>
    /// Interaction logic for SearchKardexChangeMeasure.xaml
    /// </summary>
    public partial class SearchKardexMeasure : Page, ISearchKardexMeasureView
    {
        PresenterSearchKardexMeasure pSearchChangeMeasure;
        public SearchKardexMeasure()
        {
            InitializeComponent();
            pSearchChangeMeasure = new PresenterSearchKardexMeasure(this);
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            App.Current.MainWindow.Title = "Buscar kardex";
        }

        #region Buttons
        private void SearchBtn_Click(object sender, RoutedEventArgs e)
        {
            pSearchChangeMeasure.SearchByAllParameters();
        }

        private void ModifyWaterReadindBtn_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new ModifyKardexMeasure((Model.Kardex)KardexFindedDgv.SelectedItem));
        }
        #endregion

        #region Fields
        public string Name
        {
            get
            {
                return NameTxt.Text;
            }
        }

        public string LastName
        {
            get
            {
                return LastNameTxt.Text;
            }
        }

        public string Square
        {
            get
            {
                return SquareTxt.Text;
            }
        }

        public string Allotment
        {
            get
            {
                return AllotmentTxt.Text;
            }
        }

        public ICollection<Model.Kardex> kardexList
        {
            get
            {
                if (KardexFindedDgv.ItemsSource == null)
                    new List<Model.FeesAndFines>();
                return (ICollection<Model.Kardex>)KardexFindedDgv.ItemsSource;
            }
            set
            {
                KardexFindedDgv.ItemsSource = null;
                KardexFindedDgv.ItemsSource = value;
            }
        }
        #endregion

        #region Message
        public void NotifyErrorMessage(string MessageValue)
        {
            MessageBox.Show(App.Current.MainWindow, MessageValue, "Error!!!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }

        public void NotifySystemMessage(string MessageValue)
        {
            MessageBox.Show(App.Current.MainWindow, MessageValue, "Atencion!!!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }
        #endregion
    }
}
